package com.tuni.birthdaymoney.service;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Calendar;

import com.mysema.query.types.expr.BooleanExpression;
import com.tuni.birthdaymoney.persistence.entity.Person;
import com.tuni.birthdaymoney.persistence.entity.Role;

public interface PersonService {
    /**
     * Returns all persons who:<br/>
     * 1. Have birthday at specified date (without matter of year) (and)<br/>
     * 2. Have Fired = false<br/>
     * 3. Have WantToCelebrate = true
     * 
     * @param date
     *            The date
     * @return List of persons
     */
    Iterable<Person> getPeopleWithBirthdayAt(Calendar date);

    /**
     * Returns all persons who:<br/>
     * 1. Have birthday from date (without matter of year) and within specified
     * period (and)<br/>
     * 2. Have Fired = false<br/>
     * 3. Have WantToCelebrate = true
     * 
     * @param date
     *            The date
     * @return List of persons
     */
    Iterable<Person> getPeopleWithBirthdaySoon(Calendar date, int periodDays);

    Iterable<Person> getAllPeople();

    Person getById(int id);

    Person getByAuthToken(String authToken);

    public Iterable<Person> findAll(BooleanExpression expression);

    public Iterable<Person> findByFirstNameAndLastName(String firstName, String lastName);

    public Person addAsUser(Person person, Role role, String password) throws NoSuchAlgorithmException, InvalidKeySpecException;

    public Person add(Person person);

    public Person updateAsUser(Person person, Role role, String password) throws NoSuchAlgorithmException, InvalidKeySpecException;

    public Person update(Person person);

    /**
     * Returns all persons who want to be notified about birthdayMan's birthday,
     * i.e.:<br/>
     * 1. Have WantToReceive = true (and)<br/>
     * 2. Have Fired = false (and)<br/>
     * 3. Are not the specified birthday man.
     * 
     * @param birthdayMan
     *            Birthday man
     * @return List of persons
     */
    public Iterable<Person> getNotificationPersons(Person birthdayMan);

    public void delete(Person person);

    public Iterable<Person> findAllOrderedByLastName(BooleanExpression expression);

}
